﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Threading;
using AmazonGlacierGUI.Core.Helpers;
using AmazonGlacierGUI.Core.Helpers.AmazonGlacier;
using AmazonGlacierGUI.Core.Model;
using AmazonGlacierGUI.UI.Infrastructure;
using AmazonGlacierGUI.UI.Infrastructure.MVVMFramework;
using GalaSoft.MvvmLight.Command;

namespace AmazonGlacierGUI.UI.ViewModels
{
    //17-Sep-2012 Priyan R
    public class DownloadViewModel:AppViewModelBase
    {        
        public DownloadViewModel()
        {
    
            WireCommands();
            AddValidation(() => DownloadArchiveToPath,
                          () =>
                              {
                                  if (!Directory.Exists(DownloadArchiveToPath))
                                      return new ValidationResultData("Directory not exist");
                                  return ValidationResultData.Success;
                              });

        }
        void WireCommands()
        {
            
        }
        private string _downloadArchiveToPath;   
        public string DownloadArchiveToPath
        {
            get { return _downloadArchiveToPath; }
            set
            {
                if (_downloadArchiveToPath != value)
                {
                    _downloadArchiveToPath = value;                    
                    RaisePropertyChanged(() => DownloadArchiveToPath);
                }
            }
        }

        private BrowseArchiveTypeEnum _browseArchiveType;
        public BrowseArchiveTypeEnum BrowseArchiveType
        {
            get { return _browseArchiveType; }
            set
            {
                if (_browseArchiveType != value)
                {
                    _browseArchiveType = value;                    
                    RaisePropertyChanged(() => BrowseArchiveType);
                    RaisePropertyChanged(() => CanBrowse);
                }
            }
        }        
        public bool CanBrowse
        {
            get
            {
                return BrowseArchiveType == BrowseArchiveTypeEnum.FromUploadHistory
                       || BrowseArchiveType == BrowseArchiveTypeEnum.FromAmazonInventory;
            }           
        }

        
        public enum BrowseArchiveTypeEnum
        {
           FromUploadHistory,
           FromAmazonInventory,
           ByArchiveId
        }
        
    }
}
